﻿import Vue from 'vue';
import Router from 'vue-router';
Vue.use(Router)
import Login from '@/Views/User/Login.cshtml';
let router = new Router({
    routes: [
        {
            path: "/login",
            name: "login",
            component: Login
        },
        {
            path: "/",
            redirect: "login"
        },
        {
            path: "/main",
            name: "main",
            component: Main,
            children: [
                {
                    path: "/student",
                    name: "student",
                    component: Student,
                    meta: { isAuth: true, title: '学生列表' }
                },
                {
                    path: "/Welcome",
                    name: "Welcome",
                    component: Welcome
                },
                {
                    path: "/main",
                    redirect: '/Welcome'
                },
                {
                    path: "/main",
                    redirect: '/Welcome'
                },
                {
                    path: "/Xsgl",
                    name: "Xsgl",
                    component: Xsgl
                },
                {
                    path: "/Xsglfp",
                    name: "Xsglfp",
                    component: Xsglfp
                },
                {
                    path: "/Khkfjh",
                    name: "Khkfjh",
                    component: Khkfjh
                },
                {
                    path: "/khxxgl",
                    name: "khxxgl",
                    component: khxxgl
                },
                {
                    path: "/khlsgl",
                    name: "khlsgl",
                    component: khlsgl
                },
                {
                    path: "/Fwcj",
                    name: "Fwcj",
                    component: Fwcj
                },
                {
                    path: "/Fwfp",
                    name: "Fwfp",
                    component: Fwfp
                },
                {
                    path: "/Fwcl",
                    name: "Fwcl",
                    component: Fwcl
                }, {
                    path: "/Fwfk",
                    name: "Fwfk",
                    component: Fwfk
                }, {
                    path: "/Fwgd",
                    name: "Fwgd",
                    component: Fwgd
                }
                , {
                    path: "/Yhgl",
                    name: "Yhgl",
                    component: Yhgl
                },
                {
                    path: "/Quan",
                    name: "Quan",
                    component: Quan
                },
                {
                    path: "/jsgl",
                    name: "jsgl",
                    component: jsgl
                },

            ]
        },
    ]
})


//路由守卫
router.beforeEach((to, from, next) => {
    // console.log('beforeEach',to,from);
    if (to.meta.isAuth) {
        if (localStorage.getItem('token') == "111") {
            next();
        } else {
            alert('你无权限查看')
        }
    } else {
        next();
    }

})

router.afterEach((to, from) => {
    if (to.meta.title) {
        document.title = to.meta.title;
    } else {
        document.title = "vue2"
    }
})

export default router;